<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>项目管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
</head>
<body>
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader">
                <p>
                    <span id="welcome"></span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <span><a href="/">退出</a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span id="localdate"></span><br/>
                </p>
            </div>
            <div id="topheader">
                <h1 id="title">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="adhomepage.html">首页
                </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">评分
                </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="scoreCount.html">成绩统计</a>
                </h1>
            </div>
            <div id="navigation"></div>
        </div>
        <div id="content">
            <p id="whereami"></p>
            <h1>运动员名单</h1>
            <table class="table">
                <thead>
                    <tr class="table_header">
                        <td>排名</td>
                        <td>分数</td>
                        <td>参报学生</td>
                        <td>性别</td>
                        <td>学生编号</td>
                        <td>专业</td>
                        <td>电话</td>
                        <td>运动项目</td>
                        <td>比赛时间</td>
                        <td>比赛地点</td>
                        <td>操作</td>
                    </tr>
                </thead>
                <tbody id="context"></tbody>
            </table>
        </div>
    </div>
    <div id="footer">
        <div id="footer_bg">ABC@126.com</div>
    </div>
</div>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">

    let map = {};
    fillCustomMessage();

    $.get({url: "/aname?adminId=" + map.id, success(data) {$("#welcome").html("欢迎：<span style='color: #ffffff'>" + data + "</span>")}})

    console.log(window.location.href.split("=")[1]);
    getParticipants();

    function getParticipants() {
        let context = $("#context");
        context.empty();
        $.get({
            url: "/event/participants?eventId=" + window.location.href.split("=")[1],
            success(data) {
                console.log(data);
                $.each(data.participantsList, function (index, element) {
                    context.append("<tr class=" + (index % 2 == 0 ? "row1": "row2") +">\n" +
                        "    <td>" + (index + 1) +  "</td>\n" +
                        "    <td>" + (null == element.college ? "null" : element.college) + "</td>\n" +
                        "    <td>" + element.name +  "</td>\n" +
                        "    <td>" + element.sex +  "</td>\n" +
                        "    <td>" + element.username +  "</td>\n" +
                        "    <td>" + element.major +  "</td>\n" +
                        "    <td>" + element.phone +  "</td>\n" +
                        "    <td>" + data.name +  "</td>\n" +
                        "    <td>" + new Date(data.time).toLocaleDateString() + "</td>\n" +
                        "    <td>" + data.location + "</td>\n" +
                        "    <td>\n" +
                        "        <a href=addScore.html?id=" + element.id + ">打分</a>&nbsp;\n" +
                        "    </td>\n" +
                        "</tr>");
                });
            }
        });
        context.trigger("create");
    }

    // 读取cookie并写入到map
    function fillCustomMessage() {
        // let map = {}
        let messages = document.cookie.split("; ");
        for (let i = 0; i < messages.length; i++) {
            let ms = messages[i].split("=");
            map[ms[0]] = ms[1];
        }
        // $("#title").text(map.message);
        $("#footer_bg").text(map.email);
        $("#localdate").text(map.time);
    }
</script>
</body>
</html>



